<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="网络基础：  OSI与TCP/IP各层的结构与功能，都有哪些协议。OSI 七层模型 ：（应表会传网数物）应用层，表示层，会话层，传输层（路由器，交换机），网络层（路由器，交换机），数据链路层，物理层TCP、IP：应传网数物应用层：文件传输,电子邮件表示层：数据格式化，代码转换会话层：解除或建立与别人的接点的联系传输层：提供端对端的接口 TCP UDP网络层：为数据包选择路由IP,路由器三层交换机(">
<meta property="og:type" content="article">
<meta property="og:title" content="网络基础">
<meta property="og:url" content="http://yoursite.com/2017/11/05/network/网络基础/index.html">
<meta property="og:site_name" content="Tissan">
<meta property="og:description" content="网络基础：  OSI与TCP/IP各层的结构与功能，都有哪些协议。OSI 七层模型 ：（应表会传网数物）应用层，表示层，会话层，传输层（路由器，交换机），网络层（路由器，交换机），数据链路层，物理层TCP、IP：应传网数物应用层：文件传输,电子邮件表示层：数据格式化，代码转换会话层：解除或建立与别人的接点的联系传输层：提供端对端的接口 TCP UDP网络层：为数据包选择路由IP,路由器三层交换机(">
<meta property="og:updated_time" content="2017-11-06T00:44:49.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="网络基础">
<meta name="twitter:description" content="网络基础：  OSI与TCP/IP各层的结构与功能，都有哪些协议。OSI 七层模型 ：（应表会传网数物）应用层，表示层，会话层，传输层（路由器，交换机），网络层（路由器，交换机），数据链路层，物理层TCP、IP：应传网数物应用层：文件传输,电子邮件表示层：数据格式化，代码转换会话层：解除或建立与别人的接点的联系传输层：提供端对端的接口 TCP UDP网络层：为数据包选择路由IP,路由器三层交换机(">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 'undefined',
      author: 'Java程序员'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/11/05/network/网络基础/"/>





  <title>网络基础 | Tissan</title>
  














</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Tissan</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/11/05/network/网络基础/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="罗天翔">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/uploads/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Tissan">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">网络基础</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-11-05T16:12:09+08:00">
                2017-11-05
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/network/" itemprop="url" rel="index">
                    <span itemprop="name">network</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-comment-o"></i>
              </span>
              
                <a href="/2017/11/05/network/网络基础/#SOHUCS" itemprop="discussionUrl">
                  <span id="changyan_count_unit" class="post-comments-count hc-comment-count" data-xid="2017/11/05/network/网络基础/" itemprop="commentsCount"></span>
                </a>
              
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>网络基础：</p>
<ol>
<li>OSI与TCP/IP各层的结构与功能，都有哪些协议。<br>OSI 七层模型 ：（应表会传网数物）应用层，表示层，会话层，传输层（路由器，交换机），网络层（路由器，交换机），数据链路层，物理层<br>TCP、IP：应传网数物<br>应用层：文件传输,电子邮件<br>表示层：数据格式化，代码转换<br>会话层：解除或建立与别人的接点的联系<br>传输层：提供端对端的接口 TCP UDP<br>网络层：为数据包选择路由IP,路由器三层交换机(比数据链路层多实现了数据包的高速转发)<br>数据链路层：以太网交换机，转发网络层的数据控制帧在数据链路层建立维持释放<br>物理层：中继器，集线器</li>
</ol>
<ol>
<li><p>TCP与UDP的区别。<br>(1)TCP：必须和对方建立可靠的连接，保证数据顺序<br>(2)UDP：不建立链接，面向报文(ping 向对方主机发送UDP数据报)</p>
</li>
<li><p>TCP报文结构。<br>（1）源端口，目的端口，序列号，确认序列号，窗口，校验和，紧急指针，数据（数据报）</p>
</li>
<li><p>TCP的三次握手与四次挥手过程，各个状态名称与含义，TIMEWAIT的作用。<br><a href="http://www.cnblogs.com/bizhu/archive/2012/05/12/2497493.html" target="_blank" rel="external">http://www.cnblogs.com/bizhu/archive/2012/05/12/2497493.html</a><br>3次是最少的保证状态，<br>2次肯定不够如果发生：B接收到A的卡了好久才到却废弃的ack1，就会一直等待浪费资源<br>4次是多余的，因为A要不要传数据是要A说了算</p>
</li>
</ol>
<ol>
<li><p>Http的状态码含义。<br>502:Bad GateWay（上游服务器作为网关不同意交换数据）<br>504:GateWay TimeOut（接收到请求但是没有接收到及时的相应）</p>
</li>
<li><p>Http的几种类型。<br>get：请求数据<br>head：用于获取数据报头<br>post：向指定资源提交处理请求<br>put：提交新的数据取代指定数据（和post比较幂等性，post提交相同数据会创建新资源，put是）<br>delete：删除指定资源<br>connect：<br>options：允许客户端查看服务器性能<br>trace：回显服务器收到的请求</p>
</li>
</ol>
<ol>
<li><p>Http1.1和Http1.0的区别<br>1.0就是tcp3次握手<br>http持久链接，同一个http连接能够处理多次请求，大大减少了网络包</p>
</li>
<li><p>Http怎么处理长连接。<br>(1)http长连接：保证tcp连接不断开，Connection: Keep-alive timeout<br>(2)<a href="http://blog.jobbole.com/93960/" target="_blank" rel="external">http://blog.jobbole.com/93960/</a><br>(3)3次握手犹如 去别人做客，你去人家肯定要最后确认的是你自己<br>为什么需要4次挥手<br>（1)我先走了拜拜？(2) 拜拜； 路上小心； （4）好的，你也路上小心   为什么要说第4句就是说话语权才提交方，（2）和（3）在一次是要保证数据的传输完成</p>
</li>
</ol>
<ol>
<li><p>Cookie与Session的作用于原理。<br>1.cookie保存sessionID，这样能够保证每次http从无状态变成有状态 session放在内存，redis</p>
</li>
<li><p>电脑上访问一个网页，整个过程是怎么样的：DNS、HTTP、TCP、OSPF、IP、ARP。 （寻找ip和端口）<br>1.浏览器有DNS缓存，系统缓存，路由器缓存，根域名服务器<br>2.请求到跟域名服务器，获取到权限域名服务器的ip，在权限域名服务器获取所要访问主机的ip，端口要自己服务器自己来路由<br>3.建立tcp连接3次握手<br>SYN,ACK是标志位<br>SEQ，AN是数据包序号<br>SYN=1，ACK=0，SEQ=200 发送一个SYN请求，发送端的初始数据包序号为200<br>SYN=1，ACK=0，SEQ=4800，AN=201的意思：接收端确认信息，且初始端的初始数据包序号为4800<br>4.浏览器将请求封装给http报文，浏览器将该域名cookie放在http请求头里<br>5.收到请求后，产生相应报文，将返回的数据展示出来</p>
</li>
</ol>
<ol>
<li>Ping的整个过程。ICMP报文是什么。控制报文协议<br><a href="http://blog.csdn.net/guoweimelon/article/details/50859658" target="_blank" rel="external">http://blog.csdn.net/guoweimelon/article/details/50859658</a></li>
</ol>
<ol>
<li>IP地址分类。<br>A:1.0.0.0 ~ 126.0.0.0<br>B:128.0.0.0 ~ 191.255.255.255<br>C:192.0.0.0 ~ 223.255.255.255<br>D:多点广播 DDOS攻击<br>255．255．255．255 当前子网的广播地址</li>
</ol>
<ol>
<li>路由器与交换机区别。 都是一根网线上网<br>交换机是拨号独立的宽带，互不影响<br>路由器是虚拟拨号公用同一个宽带账号</li>
</ol>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/uploads/wechat.png" alt="罗天翔 WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="/uploads/ali.jpg" alt="罗天翔 Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/11/05/network/操作系统基础/" rel="next" title="操作系统基础">
                <i class="fa fa-chevron-left"></i> 操作系统基础
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/11/05/jvm/JVM基础/" rel="prev" title="JVM基础">
                JVM基础 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="SOHUCS"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel sidebar-panel-active">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/uploads/avatar.jpg"
               alt="罗天翔" />
          <p class="site-author-name" itemprop="name">罗天翔</p>
           
              <p class="site-description motion-element" itemprop="description">一次就把事情做对.</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives/">
                <span class="site-state-item-count">74</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/louiegit/" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="" target="_blank" title="微信">
                  
                    <i class="fa fa-fw fa-wechat"></i>
                  
                  微信
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">罗天翔</span>
</div>


<div class="powered-by">
  NBA & Code. What?
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  




  
    <script type="text/javascript">
    (function(){
      var appid = 'cyt9ceIwz';
      var conf = 'c6226e2bfb7e9c65efc235736edc5074';
      var width = window.innerWidth || document.documentElement.clientWidth;
      if (width < 960) {
      window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){
        window.changyan.api.config({appid:appid,conf:conf})});
      }
    })();
    </script>
    <script type="text/javascript" src="https://assets.changyan.sohu.com/upload/plugins/plugins.count.js"></script>
  




  





  

  

  

  

  

  

</body>
</html>
